import { DataTypes } from 'sequelize';
import sequelize from '../config/db.js';

const Visit = sequelize.define('Visit', {
  ip: {
    type: DataTypes.STRING(45),
    allowNull: false,
    validate: {
      isIP: true,
    },
  },
  user_agent: {
    type: DataTypes.TEXT,
    allowNull: false,
  },
  visited_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
  },
  url: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  referrer: {
    type: DataTypes.STRING,
    allowNull: true,
  },
});

export default Visit;